package com.sunzm.dynamic_rule.pojo;

import java.io.Serializable;
import java.util.HashMap;

/**
 * 规则参数中的原子条件封装实体
 */
public class RuleAtomicParam implements Serializable {
    /**
     * 事件的类型要求
     */
    private String eventId;
    /**
     * 事件的属性要求
     */
    private HashMap<String, String> properties;
    /**
     * 规则要求的阈值 (比如大于或者小于多少次,目前只支持大于)
     */
    private int threshold;
    /**
     * 用于记录真正查询到的匹配的次数
     */
    private int realCount;
    /**
     * 要求事件发生时间范围的起始时间
     */
    private long rangeStart;
    /**
     * 要求事件发生时间范围的结束时间
     */
    private long rangeEnd;

    /**
     * 条件对应的clickhouse查询sql
     */
    private String countQuerySql;

    /**
     * 用于记录初始 range start
     */
    private long originStart;
    public void setOriginStart(long originStart){
        this.originStart = originStart;
        this.rangeStart = originStart;
    }

    /**
     * 用于记录初始 range end
     */
    private long originEnd;
    public void setOriginEnd(long originEnd){
        this.originEnd = originEnd;
        this.rangeEnd = originEnd;
    }

    public RuleAtomicParam() {
    }

    public RuleAtomicParam(String eventId, HashMap<String, String> properties, int threshold, long rangeStart, long rangeEnd) {
        this.eventId = eventId;
        this.properties = properties;
        this.threshold = threshold;
        this.rangeStart = rangeStart;
        this.rangeEnd = rangeEnd;
    }

    public String getEventId() {
        return eventId;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public HashMap<String, String> getProperties() {
        return properties;
    }

    public void setProperties(HashMap<String, String> properties) {
        this.properties = properties;
    }

    public int getThreshold() {
        return threshold;
    }

    public void setThreshold(int threshold) {
        this.threshold = threshold;
    }

    public long getRangeStart() {
        return rangeStart;
    }

    public void setRangeStart(long rangeStart) {
        this.rangeStart = rangeStart;
    }

    public long getRangeEnd() {
        return rangeEnd;
    }

    public void setRangeEnd(long rangeEnd) {
        this.rangeEnd = rangeEnd;
    }

    public int getRealCount() {
        return realCount;
    }

    public void setRealCount(int realCount) {
        this.realCount = realCount;
    }

    public String getCountQuerySql() {
        return countQuerySql;
    }

    public void setCountQuerySql(String countQuerySql) {
        this.countQuerySql = countQuerySql;
    }

    public long getOriginStart() {
        return originStart;
    }

    public long getOriginEnd() {
        return originEnd;
    }

    @Override
    public String toString() {
        return "RuleAutomicParam{" +
                "eventId='" + eventId + '\'' +
                ", properties=" + properties +
                ", threshold=" + threshold +
                ", realCount=" + realCount +
                ", rangeStart=" + rangeStart +
                ", rangeEnd=" + rangeEnd +
                '}';
    }
}
